package com.foxzzz.operation;

import com.foxzzz.database.SqlExecutor;

import java.util.List;

public class InitDataBaseOperation {
    public final static String EXSIT_TABLE = "SELECT * FROM INFORMATION_SCHEMA.TABLES  WHERE TABLE_NAME='SYS_CONFIG'";
    public final static String CREATE_TAB_CURRENCY_INFO="CREATE TABLE CURRENCY_INFO(NAME VARCHAR(200) PRIMARY KEY,NBT TEXT,VALUE BIGINT)";
    public final static String CREATE_TAB_ACCOUNT="CREATE TABLE ACCOUNT(PLAYER VARCHAR(200) PRIMARY KEY,VALUE BIGINT)";
    public final static String CREATE_TAB_SYS_CONFIG = "CREATE TABLE SYS_CONFIG(KEY VARCHAR(200) PRIMARY KEY,VAL VARCHAR(1000))";
    public final static String CREATE_TAB_FUNCTION = "CREATE TABLE INFORMATION_SCHEMA.FUNCTION(NAME VARCHAR(200) PRIMARY KEY)";
    public final static String CREATE_TAB_ITEM_STORE_DATA = "CREATE TABLE ITEM_STORE_DATA(ID VARCHAR(200) PRIMARY KEY,NAME VARCHAR(200),PLAYER VARCHAR(200),NBT TEXT,NUM BIGINT)";
    public final static String CREATE_TAB_ITEM_SHOP_DATA = "CREATE TABLE ITEM_SHOP_DATA(ID VARCHAR(200) PRIMARY KEY,NAME VARCHAR(200),NBT TEXT,PLAYER VARCHAR(200),PRICE BIGINT,STORE_NUM BIGINT)";

    public void init() {
        SqlExecutor.init("ItemStore/store", "6603", "sa", "_sa");
        List list = SqlExecutor.queryBySql(EXSIT_TABLE);
        if (list.size() == 0) {
            SqlExecutor.updateBySql(CREATE_TAB_SYS_CONFIG);
            SqlExecutor.updateBySql(CREATE_TAB_FUNCTION);
            SqlExecutor.updateBySql(CREATE_TAB_CURRENCY_INFO);
            SqlExecutor.updateBySql(CREATE_TAB_ACCOUNT);
            SqlExecutor.updateBySql(CREATE_TAB_ITEM_STORE_DATA);
            SqlExecutor.updateBySql(CREATE_TAB_ITEM_SHOP_DATA);

            //config
        } else {

        }
    }

    public static void main(String[] args) {
        new InitDataBaseOperation().init();

    }
}